-- SimpleSavedVarsDemo.lua
local ADDON_NAME = "SimpleSavedVarsDemo"
SimpleSavedVarsDemoDB = SimpleSavedVarsDemoDB or {message = "Hello, World!"}

-- 创建主框架
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")

-- 事件处理
frame:SetScript("OnEvent", function(self, event, addonName)
    if event == "ADDON_LOADED" and addonName == ADDON_NAME then
        print("插件加载完成!")
        print("当前保存的消息:", SimpleSavedVarsDemoDB.message)

        -- 添加斜杠命令
        SLASH_SIMPLE1 = "/simple"
        SlashCmdList["SIMPLE"] = function(msg)
            if msg == "show" then
                print("当前保存的消息:", SimpleSavedVarsDemoDB.message)
            elseif msg:sub(1, 4) == "set " then
                local newMessage = msg:sub(5)
                SimpleSavedVarsDemoDB.message = newMessage
                print("消息已更新为:", newMessage)
            else
                print("用法:")
                print("/simple show - 显示当前消息")
                print("/simple set [消息] - 设置新消息")
            end
        end

        print("输入 /simple show 查看当前消息")
        print("输入 /simple set [新消息] 更新消息")
    end
end)